<template>
	<view class="content">
		<navigator open-type="reLaunch" url="/pages/user/user">跳转用户</navigator>
		<image class="logo" src="/static/logo.png"></image>
		<button @click="clickToast">点击弹出toast</button>
		<button @click="clickHidden">点击隐藏</button>
		<button @click="clickSave">点击存储数据</button>
		<button @click="requestClick">点击请求网络</button>
		<view class="">{{name}}</view>
		<view v-for="item in listData">
			{{"标题：" + item.title + "\n"+ "点赞数量："+ item.view_count}}
		</view>
		<view class="">{{title}}</view>
	</view>
</template>

<script setup>
const title = ref("小文")
const name = uni.getStorageSync('key1')
let listData = ref([])

console.log(name)

async function requestClick(){
	 // uni.request({
	 // 	url: "https://tea.qingnian8.com/api/bizhi/wallNewsList",
		// method:'GET',
		// success: (e) => {
		// 	console.log(e.data.data)
		// 	listData.value = e.data.data
		// },
		// fail: (e) => {
		// 	console.log(e)
		// },
		// complete(e) {
		// 	console.log(e)
		// }
	 // })
	 
	 // uni.request({
	 // 	url: "https://tea.qingnian8.com/api/bizhi/wallNewsList",
	 // 	method:'GET',
	 // }).then((e)=>{
		//  listData.value = e.data.data
	 // }).catch((e)=>{
		 
	 // })
	 
	 let res = await uni.request({
	 	url: "https://tea.qingnian8.com/api/bizhi/wallNewsList",
	 	method:'GET',
	 })
	 listData.value = res.data.data
 }
function clickSave(){
	uni.setStorageSync('key1','xiaowen')	
	let name = uni.getStorageSync('key1')
	console.log(name)
}
onLoad(()=>{
		uni.startPullDownRefresh()
})
onPullDownRefresh((e)=>{
	 console.log('refresh');
	 setTimeout(()=>{
	 		uni.stopPullDownRefresh()
	 	
	 },1000)
	 
 })
  

 function clickToast(){
	 uni.showToast({
	 	 	 	title:"测试弹窗测试弹窗测试弹窗测试弹窗测试弹窗测试弹窗测试弹窗测试弹窗",
	 	 	 	// duration:5000,
				//mask: true,
				icon: "none",
				image:"../../static/logo.png"
	 	 })
 }
 function clickHidden(){
	 uni.hideToast()
 }
 
 
 onReachBottom(()=>{
	 console.log("触发底部")	 
	
 })
</script>


<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
